#include <iostream>
#include <cstring>
using namespace std;



/*
    C++ 输出语句        cout << 变量名
        endl 换行
        << 输出流
        使用cout输出不需要在意数据类型
    char * 不能直接打印出地址
    需要强转成void *
        char str1[32] = "Hello World!";
        char *str2 = "Hello World!";
        cout << &str1 << endl;              打印的是数组的地址
        cout << (void *)str1 << endl;       打印的是数组首元素的地址    
        cout << &str2 << endl;              打印的是指针变量的地址
        cout << (void *)str2 << endl;       打印的是指针变量指向的地址
*/

struct test
{
    int a;
    double b;
    char c[32];
};
union date
{
    int a;
    double b;
};
enum color
{
    red,
    green,
    blue,
    yellow
};

int main() 
{
    cout << "Hello World!" << endl;
    int a = 1020; 
    double b = 10.1;
    char c[32] = "Hello World!";
    cout << a;    
    cout << b << '\n';    
    cout << c;
    cout << endl << "同时打印多个变量"<< endl;
    cout << a << b << c << endl;   

    cout << "练习:" << endl;
    // 使用cout打印结构体，共用体，枚举，变量地址
    cout << "结构体" << endl;
    struct test test = {1020, 10.1, "Hello World!"};
    cout << test.a << endl;
    cout << test.b << endl;
    cout << test.c << endl;

    cout << "共用体" << endl;
    union date date;
    date.a = 1020;
    date.b = 10.1;
    cout << date.a << endl; // 输出是值是date.b的值，转成int类型
    cout << date.b << endl;

    cout << "枚举" << endl;
    cout << red << endl;
    cout << green << endl;
    cout << blue << endl;
    cout << yellow << endl;

    cout << "变量地址" << endl;
    cout << &a << endl;
    const char * str = "Hello World!";
    cout << (void *)str << endl; // 打印的是 str的指针指向的地址
    cout << &str << endl; // 输出是str的指针地址


    return 0;
}

// 使用g++编译c++程序
// g++ test.cpp -o test.out
// arm-linux-g++ test.cpp 
